//TODO clean up includes
#include <cv.h>
#include <highgui.h>
#include "abstractProbabilityTransformer.hpp"
#include "abstractFilter.hpp"
#include "resourceTracker.h"
#include "faceDetector.h"
#include "AbstractHandTracker.hpp"
#include "HIVideoCapture.hpp"
#include "handLocaliser.hpp"
#include "AbstractHandTrackerTest.hpp"

#include <iostream>
#include "gtest.h"

#include "HandTrackerLKGREYwMSwBPwBGESwFOx.hpp"


//FIXNOW: normalise error according to tracking rect size? (include both normalised and raw error)

using namespace cv;



class HandTrackerLKGREYwMSwBPwBGESwFOxTest : public ::AbstractHandTrackerTest {
protected:
	void setHandTracker(int trackerCode);
};


void HandTrackerLKGREYwMSwBPwBGESwFOxTest::setHandTracker(int trackerCode) {
	
	switch ( trackerCode ) {
	
		case 0:
			ht = HandTrackerLKGREYwMSwBPwBGESwFOx::init( hl->getProbabilityTransformer(), trackingRect, frame, Ptr< AbstractFilter >(new OpenFilter(0)), 0.0, 0.5 );
			break;
		case 1:
			ht = HandTrackerLKGREYwMSwBPwBGESwFOx::init( hl->getProbabilityTransformer(), trackingRect, frame, Ptr< AbstractFilter >(new OpenFilter(0)), 0.0, 0.8 );
			break;
		case 2:
			ht = HandTrackerLKGREYwMSwBPwBGESwFOx::init( hl->getProbabilityTransformer(), trackingRect, frame, Ptr< AbstractFilter >(new OpenFilter(0)), 0.0, 1.0 );
			break;
		case 3:
			ht = HandTrackerLKGREYwMSwBPwBGESwFOx::init( hl->getProbabilityTransformer(), trackingRect, frame, Ptr< AbstractFilter >(new OpenFilter(0)), 0.5, 0.5 );
			break;
		case 4:
			ht = HandTrackerLKGREYwMSwBPwBGESwFOx::init( hl->getProbabilityTransformer(), trackingRect, frame, Ptr< AbstractFilter >(new OpenFilter(0)), 0.5, 0.8 );
			break;
		case 5:
			ht = HandTrackerLKGREYwMSwBPwBGESwFOx::init( hl->getProbabilityTransformer(), trackingRect, frame, Ptr< AbstractFilter >(new OpenFilter(0)), 0.5, 1.0 );
			break;
		case 6:
			ht = HandTrackerLKGREYwMSwBPwBGESwFOx::init( hl->getProbabilityTransformer(), trackingRect, frame, Ptr< AbstractFilter >(new OpenFilter(0)), 0.8, 0.5 );
			break;
		case 7:
			ht = HandTrackerLKGREYwMSwBPwBGESwFOx::init( hl->getProbabilityTransformer(), trackingRect, frame, Ptr< AbstractFilter >(new OpenFilter(0)), 0.8, 0.8 );
			break;
		case 8:
			ht = HandTrackerLKGREYwMSwBPwBGESwFOx::init( hl->getProbabilityTransformer(), trackingRect, frame, Ptr< AbstractFilter >(new OpenFilter(0)), 0.8, 1.0 );
			break;
		case 9:
			ht = HandTrackerLKGREYwMSwBPwBGESwFOx::init( hl->getProbabilityTransformer(), trackingRect, frame, Ptr< AbstractFilter >(new OpenFilter(1)), 0.0, 0.5 );
			break;
		case 10:
			ht = HandTrackerLKGREYwMSwBPwBGESwFOx::init( hl->getProbabilityTransformer(), trackingRect, frame, Ptr< AbstractFilter >(new OpenFilter(1)), 0.0, 0.8 );
			break;
		case 11:
			ht = HandTrackerLKGREYwMSwBPwBGESwFOx::init( hl->getProbabilityTransformer(), trackingRect, frame, Ptr< AbstractFilter >(new OpenFilter(1)), 0.0, 1.0 );
			break;
		case 12:
			ht = HandTrackerLKGREYwMSwBPwBGESwFOx::init( hl->getProbabilityTransformer(), trackingRect, frame, Ptr< AbstractFilter >(new OpenFilter(1)), 0.5, 0.5 );
			break;
		case 13:
			ht = HandTrackerLKGREYwMSwBPwBGESwFOx::init( hl->getProbabilityTransformer(), trackingRect, frame, Ptr< AbstractFilter >(new OpenFilter(1)), 0.5, 0.8 );
			break;
		case 14:
			ht = HandTrackerLKGREYwMSwBPwBGESwFOx::init( hl->getProbabilityTransformer(), trackingRect, frame, Ptr< AbstractFilter >(new OpenFilter(1)), 0.5, 1.0 );
			break;
		case 15:
			ht = HandTrackerLKGREYwMSwBPwBGESwFOx::init( hl->getProbabilityTransformer(), trackingRect, frame, Ptr< AbstractFilter >(new OpenFilter(1)), 0.8, 0.5 );
			break;
		case 16:
			ht = HandTrackerLKGREYwMSwBPwBGESwFOx::init( hl->getProbabilityTransformer(), trackingRect, frame, Ptr< AbstractFilter >(new OpenFilter(1)), 0.8, 0.8 );
			break;
		case 17:
			ht = HandTrackerLKGREYwMSwBPwBGESwFOx::init( hl->getProbabilityTransformer(), trackingRect, frame, Ptr< AbstractFilter >(new OpenFilter(1)), 0.8, 1.0 );
			break;
		case 18:
			ht = HandTrackerLKGREYwMSwBPwBGESwFOx::init( hl->getProbabilityTransformer(), trackingRect, frame, Ptr< AbstractFilter >(new OpenFilter(2)), 0.0, 0.5 );
			break;
		case 19:
			ht = HandTrackerLKGREYwMSwBPwBGESwFOx::init( hl->getProbabilityTransformer(), trackingRect, frame, Ptr< AbstractFilter >(new OpenFilter(2)), 0.0, 0.8 );
			break;
		case 20:
			ht = HandTrackerLKGREYwMSwBPwBGESwFOx::init( hl->getProbabilityTransformer(), trackingRect, frame, Ptr< AbstractFilter >(new OpenFilter(2)), 0.0, 1.0 );
			break;
		case 21:
			ht = HandTrackerLKGREYwMSwBPwBGESwFOx::init( hl->getProbabilityTransformer(), trackingRect, frame, Ptr< AbstractFilter >(new OpenFilter(2)), 0.5, 0.5 );
			break;
		case 22:
			ht = HandTrackerLKGREYwMSwBPwBGESwFOx::init( hl->getProbabilityTransformer(), trackingRect, frame, Ptr< AbstractFilter >(new OpenFilter(2)), 0.5, 0.8 );
			break;
		case 23:
			ht = HandTrackerLKGREYwMSwBPwBGESwFOx::init( hl->getProbabilityTransformer(), trackingRect, frame, Ptr< AbstractFilter >(new OpenFilter(2)), 0.5, 1.0 );
			break;
		case 24:
			ht = HandTrackerLKGREYwMSwBPwBGESwFOx::init( hl->getProbabilityTransformer(), trackingRect, frame, Ptr< AbstractFilter >(new OpenFilter(2)), 0.8, 0.5 );
			break;
		case 25:
			ht = HandTrackerLKGREYwMSwBPwBGESwFOx::init( hl->getProbabilityTransformer(), trackingRect, frame, Ptr< AbstractFilter >(new OpenFilter(2)), 0.8, 0.8 );
			break;
		case 26:
			ht = HandTrackerLKGREYwMSwBPwBGESwFOx::init( hl->getProbabilityTransformer(), trackingRect, frame, Ptr< AbstractFilter >(new OpenFilter(2)), 0.8, 1.0 );
			break;
		case 27:
			ht = HandTrackerLKGREYwMSwBPwBGESwFOx::init( hl->getProbabilityTransformer(), trackingRect, frame, Ptr< AbstractFilter >(new OpenFilter(3)), 0.0, 0.5 );
			break;
		case 28:
			ht = HandTrackerLKGREYwMSwBPwBGESwFOx::init( hl->getProbabilityTransformer(), trackingRect, frame, Ptr< AbstractFilter >(new OpenFilter(3)), 0.0, 0.8 );
			break;
		case 29:
			ht = HandTrackerLKGREYwMSwBPwBGESwFOx::init( hl->getProbabilityTransformer(), trackingRect, frame, Ptr< AbstractFilter >(new OpenFilter(3)), 0.0, 1.0 );
			break;
		case 30:
			ht = HandTrackerLKGREYwMSwBPwBGESwFOx::init( hl->getProbabilityTransformer(), trackingRect, frame, Ptr< AbstractFilter >(new OpenFilter(3)), 0.5, 0.5 );
			break;
		case 31:
			ht = HandTrackerLKGREYwMSwBPwBGESwFOx::init( hl->getProbabilityTransformer(), trackingRect, frame, Ptr< AbstractFilter >(new OpenFilter(3)), 0.5, 0.8 );
			break;
		case 32:
			ht = HandTrackerLKGREYwMSwBPwBGESwFOx::init( hl->getProbabilityTransformer(), trackingRect, frame, Ptr< AbstractFilter >(new OpenFilter(3)), 0.5, 1.0 );
			break;
		case 33:
			ht = HandTrackerLKGREYwMSwBPwBGESwFOx::init( hl->getProbabilityTransformer(), trackingRect, frame, Ptr< AbstractFilter >(new OpenFilter(3)), 0.8, 0.5 );
			break;
		case 34:
			ht = HandTrackerLKGREYwMSwBPwBGESwFOx::init( hl->getProbabilityTransformer(), trackingRect, frame, Ptr< AbstractFilter >(new OpenFilter(3)), 0.8, 0.8 );
			break;
		case 35:
			ht = HandTrackerLKGREYwMSwBPwBGESwFOx::init( hl->getProbabilityTransformer(), trackingRect, frame, Ptr< AbstractFilter >(new OpenFilter(3)), 0.8, 1.0 );
			break;
		default:
			ASSERT_TRUE(false);
			break;
	}
}



TEST_F(HandTrackerLKGREYwMSwBPwBGESwFOxTest, OF0BGalpha0.0BGbeta0.5locVid1c ) {
	testTracker( 0, "locVid1c" );
}

TEST_F(HandTrackerLKGREYwMSwBPwBGESwFOxTest, OF0BGalpha0.0BGbeta0.8locVid1c ) {
	testTracker( 1, "locVid1c" );
}

TEST_F(HandTrackerLKGREYwMSwBPwBGESwFOxTest, OF0BGalpha0.0BGbeta1.0locVid1c ) {
	testTracker( 2, "locVid1c" );
}

TEST_F(HandTrackerLKGREYwMSwBPwBGESwFOxTest, OF0BGalpha0.5BGbeta0.5locVid1c ) {
	testTracker( 3, "locVid1c" );
}

TEST_F(HandTrackerLKGREYwMSwBPwBGESwFOxTest, OF0BGalpha0.5BGbeta0.8locVid1c ) {
	testTracker( 4, "locVid1c" );
}

TEST_F(HandTrackerLKGREYwMSwBPwBGESwFOxTest, OF0BGalpha0.5BGbeta1.0locVid1c ) {
	testTracker( 5, "locVid1c" );
}

TEST_F(HandTrackerLKGREYwMSwBPwBGESwFOxTest, OF0BGalpha0.8BGbeta0.5locVid1c ) {
	testTracker( 6, "locVid1c" );
}

TEST_F(HandTrackerLKGREYwMSwBPwBGESwFOxTest, OF0BGalpha0.8BGbeta0.8locVid1c ) {
	testTracker( 7, "locVid1c" );
}

TEST_F(HandTrackerLKGREYwMSwBPwBGESwFOxTest, OF0BGalpha0.8BGbeta1.0locVid1c ) {
	testTracker( 8, "locVid1c" );
}

TEST_F(HandTrackerLKGREYwMSwBPwBGESwFOxTest, OF1BGalpha0.0BGbeta0.5locVid1c ) {
	testTracker( 9, "locVid1c" );
}

TEST_F(HandTrackerLKGREYwMSwBPwBGESwFOxTest, OF1BGalpha0.0BGbeta0.8locVid1c ) {
	testTracker( 10, "locVid1c" );
}

TEST_F(HandTrackerLKGREYwMSwBPwBGESwFOxTest, OF1BGalpha0.0BGbeta1.0locVid1c ) {
	testTracker( 11, "locVid1c" );
}

TEST_F(HandTrackerLKGREYwMSwBPwBGESwFOxTest, OF1BGalpha0.5BGbeta0.5locVid1c ) {
	testTracker( 12, "locVid1c" );
}

TEST_F(HandTrackerLKGREYwMSwBPwBGESwFOxTest, OF1BGalpha0.5BGbeta0.8locVid1c ) {
	testTracker( 13, "locVid1c" );
}

TEST_F(HandTrackerLKGREYwMSwBPwBGESwFOxTest, OF1BGalpha0.5BGbeta1.0locVid1c ) {
	testTracker( 14, "locVid1c" );
}

TEST_F(HandTrackerLKGREYwMSwBPwBGESwFOxTest, OF1BGalpha0.8BGbeta0.5locVid1c ) {
	testTracker( 15, "locVid1c" );
}

TEST_F(HandTrackerLKGREYwMSwBPwBGESwFOxTest, OF1BGalpha0.8BGbeta0.8locVid1c ) {
	testTracker( 16, "locVid1c" );
}

TEST_F(HandTrackerLKGREYwMSwBPwBGESwFOxTest, OF1BGalpha0.8BGbeta1.0locVid1c ) {
	testTracker( 17, "locVid1c" );
}

TEST_F(HandTrackerLKGREYwMSwBPwBGESwFOxTest, OF2BGalpha0.0BGbeta0.5locVid1c ) {
	testTracker( 18, "locVid1c" );
}

TEST_F(HandTrackerLKGREYwMSwBPwBGESwFOxTest, OF2BGalpha0.0BGbeta0.8locVid1c ) {
	testTracker( 19, "locVid1c" );
}

TEST_F(HandTrackerLKGREYwMSwBPwBGESwFOxTest, OF2BGalpha0.0BGbeta1.0locVid1c ) {
	testTracker( 20, "locVid1c" );
}

TEST_F(HandTrackerLKGREYwMSwBPwBGESwFOxTest, OF2BGalpha0.5BGbeta0.5locVid1c ) {
	testTracker( 21, "locVid1c" );
}

TEST_F(HandTrackerLKGREYwMSwBPwBGESwFOxTest, OF2BGalpha0.5BGbeta0.8locVid1c ) {
	testTracker( 22, "locVid1c" );
}

TEST_F(HandTrackerLKGREYwMSwBPwBGESwFOxTest, OF2BGalpha0.5BGbeta1.0locVid1c ) {
	testTracker( 23, "locVid1c" );
}

TEST_F(HandTrackerLKGREYwMSwBPwBGESwFOxTest, OF2BGalpha0.8BGbeta0.5locVid1c ) {
	testTracker( 24, "locVid1c" );
}

TEST_F(HandTrackerLKGREYwMSwBPwBGESwFOxTest, OF2BGalpha0.8BGbeta0.8locVid1c ) {
	testTracker( 25, "locVid1c" );
}

TEST_F(HandTrackerLKGREYwMSwBPwBGESwFOxTest, OF2BGalpha0.8BGbeta1.0locVid1c ) {
	testTracker( 26, "locVid1c" );
}

TEST_F(HandTrackerLKGREYwMSwBPwBGESwFOxTest, OF3BGalpha0.0BGbeta0.5locVid1c ) {
	testTracker( 27, "locVid1c" );
}

TEST_F(HandTrackerLKGREYwMSwBPwBGESwFOxTest, OF3BGalpha0.0BGbeta0.8locVid1c ) {
	testTracker( 28, "locVid1c" );
}

TEST_F(HandTrackerLKGREYwMSwBPwBGESwFOxTest, OF3BGalpha0.0BGbeta1.0locVid1c ) {
	testTracker( 29, "locVid1c" );
}

TEST_F(HandTrackerLKGREYwMSwBPwBGESwFOxTest, OF3BGalpha0.5BGbeta0.5locVid1c ) {
	testTracker( 30, "locVid1c" );
}

TEST_F(HandTrackerLKGREYwMSwBPwBGESwFOxTest, OF3BGalpha0.5BGbeta0.8locVid1c ) {
	testTracker( 31, "locVid1c" );
}

TEST_F(HandTrackerLKGREYwMSwBPwBGESwFOxTest, OF3BGalpha0.5BGbeta1.0locVid1c ) {
	testTracker( 32, "locVid1c" );
}

TEST_F(HandTrackerLKGREYwMSwBPwBGESwFOxTest, OF3BGalpha0.8BGbeta0.5locVid1c ) {
	testTracker( 33, "locVid1c" );
}

TEST_F(HandTrackerLKGREYwMSwBPwBGESwFOxTest, OF3BGalpha0.8BGbeta0.8locVid1c ) {
	testTracker( 34, "locVid1c" );
}

TEST_F(HandTrackerLKGREYwMSwBPwBGESwFOxTest, OF3BGalpha0.8BGbeta1.0locVid1c ) {
	testTracker( 35, "locVid1c" );
}

TEST_F(HandTrackerLKGREYwMSwBPwBGESwFOxTest, OF0BGalpha0.0BGbeta0.5TrackerTest1 ) {
	testTracker( 0, "TrackerTest1" );
}

TEST_F(HandTrackerLKGREYwMSwBPwBGESwFOxTest, OF0BGalpha0.0BGbeta0.8TrackerTest1 ) {
	testTracker( 1, "TrackerTest1" );
}

TEST_F(HandTrackerLKGREYwMSwBPwBGESwFOxTest, OF0BGalpha0.0BGbeta1.0TrackerTest1 ) {
	testTracker( 2, "TrackerTest1" );
}

TEST_F(HandTrackerLKGREYwMSwBPwBGESwFOxTest, OF0BGalpha0.5BGbeta0.5TrackerTest1 ) {
	testTracker( 3, "TrackerTest1" );
}

TEST_F(HandTrackerLKGREYwMSwBPwBGESwFOxTest, OF0BGalpha0.5BGbeta0.8TrackerTest1 ) {
	testTracker( 4, "TrackerTest1" );
}

TEST_F(HandTrackerLKGREYwMSwBPwBGESwFOxTest, OF0BGalpha0.5BGbeta1.0TrackerTest1 ) {
	testTracker( 5, "TrackerTest1" );
}

TEST_F(HandTrackerLKGREYwMSwBPwBGESwFOxTest, OF0BGalpha0.8BGbeta0.5TrackerTest1 ) {
	testTracker( 6, "TrackerTest1" );
}

TEST_F(HandTrackerLKGREYwMSwBPwBGESwFOxTest, OF0BGalpha0.8BGbeta0.8TrackerTest1 ) {
	testTracker( 7, "TrackerTest1" );
}

TEST_F(HandTrackerLKGREYwMSwBPwBGESwFOxTest, OF0BGalpha0.8BGbeta1.0TrackerTest1 ) {
	testTracker( 8, "TrackerTest1" );
}

TEST_F(HandTrackerLKGREYwMSwBPwBGESwFOxTest, OF1BGalpha0.0BGbeta0.5TrackerTest1 ) {
	testTracker( 9, "TrackerTest1" );
}

TEST_F(HandTrackerLKGREYwMSwBPwBGESwFOxTest, OF1BGalpha0.0BGbeta0.8TrackerTest1 ) {
	testTracker( 10, "TrackerTest1" );
}

TEST_F(HandTrackerLKGREYwMSwBPwBGESwFOxTest, OF1BGalpha0.0BGbeta1.0TrackerTest1 ) {
	testTracker( 11, "TrackerTest1" );
}

TEST_F(HandTrackerLKGREYwMSwBPwBGESwFOxTest, OF1BGalpha0.5BGbeta0.5TrackerTest1 ) {
	testTracker( 12, "TrackerTest1" );
}

TEST_F(HandTrackerLKGREYwMSwBPwBGESwFOxTest, OF1BGalpha0.5BGbeta0.8TrackerTest1 ) {
	testTracker( 13, "TrackerTest1" );
}

TEST_F(HandTrackerLKGREYwMSwBPwBGESwFOxTest, OF1BGalpha0.5BGbeta1.0TrackerTest1 ) {
	testTracker( 14, "TrackerTest1" );
}

TEST_F(HandTrackerLKGREYwMSwBPwBGESwFOxTest, OF1BGalpha0.8BGbeta0.5TrackerTest1 ) {
	testTracker( 15, "TrackerTest1" );
}

TEST_F(HandTrackerLKGREYwMSwBPwBGESwFOxTest, OF1BGalpha0.8BGbeta0.8TrackerTest1 ) {
	testTracker( 16, "TrackerTest1" );
}

TEST_F(HandTrackerLKGREYwMSwBPwBGESwFOxTest, OF1BGalpha0.8BGbeta1.0TrackerTest1 ) {
	testTracker( 17, "TrackerTest1" );
}

TEST_F(HandTrackerLKGREYwMSwBPwBGESwFOxTest, OF2BGalpha0.0BGbeta0.5TrackerTest1 ) {
	testTracker( 18, "TrackerTest1" );
}

TEST_F(HandTrackerLKGREYwMSwBPwBGESwFOxTest, OF2BGalpha0.0BGbeta0.8TrackerTest1 ) {
	testTracker( 19, "TrackerTest1" );
}

TEST_F(HandTrackerLKGREYwMSwBPwBGESwFOxTest, OF2BGalpha0.0BGbeta1.0TrackerTest1 ) {
	testTracker( 20, "TrackerTest1" );
}

TEST_F(HandTrackerLKGREYwMSwBPwBGESwFOxTest, OF2BGalpha0.5BGbeta0.5TrackerTest1 ) {
	testTracker( 21, "TrackerTest1" );
}

TEST_F(HandTrackerLKGREYwMSwBPwBGESwFOxTest, OF2BGalpha0.5BGbeta0.8TrackerTest1 ) {
	testTracker( 22, "TrackerTest1" );
}

TEST_F(HandTrackerLKGREYwMSwBPwBGESwFOxTest, OF2BGalpha0.5BGbeta1.0TrackerTest1 ) {
	testTracker( 23, "TrackerTest1" );
}

TEST_F(HandTrackerLKGREYwMSwBPwBGESwFOxTest, OF2BGalpha0.8BGbeta0.5TrackerTest1 ) {
	testTracker( 24, "TrackerTest1" );
}

TEST_F(HandTrackerLKGREYwMSwBPwBGESwFOxTest, OF2BGalpha0.8BGbeta0.8TrackerTest1 ) {
	testTracker( 25, "TrackerTest1" );
}

TEST_F(HandTrackerLKGREYwMSwBPwBGESwFOxTest, OF2BGalpha0.8BGbeta1.0TrackerTest1 ) {
	testTracker( 26, "TrackerTest1" );
}

TEST_F(HandTrackerLKGREYwMSwBPwBGESwFOxTest, OF3BGalpha0.0BGbeta0.5TrackerTest1 ) {
	testTracker( 27, "TrackerTest1" );
}

TEST_F(HandTrackerLKGREYwMSwBPwBGESwFOxTest, OF3BGalpha0.0BGbeta0.8TrackerTest1 ) {
	testTracker( 28, "TrackerTest1" );
}

TEST_F(HandTrackerLKGREYwMSwBPwBGESwFOxTest, OF3BGalpha0.0BGbeta1.0TrackerTest1 ) {
	testTracker( 29, "TrackerTest1" );
}

TEST_F(HandTrackerLKGREYwMSwBPwBGESwFOxTest, OF3BGalpha0.5BGbeta0.5TrackerTest1 ) {
	testTracker( 30, "TrackerTest1" );
}

TEST_F(HandTrackerLKGREYwMSwBPwBGESwFOxTest, OF3BGalpha0.5BGbeta0.8TrackerTest1 ) {
	testTracker( 31, "TrackerTest1" );
}

TEST_F(HandTrackerLKGREYwMSwBPwBGESwFOxTest, OF3BGalpha0.5BGbeta1.0TrackerTest1 ) {
	testTracker( 32, "TrackerTest1" );
}

TEST_F(HandTrackerLKGREYwMSwBPwBGESwFOxTest, OF3BGalpha0.8BGbeta0.5TrackerTest1 ) {
	testTracker( 33, "TrackerTest1" );
}

TEST_F(HandTrackerLKGREYwMSwBPwBGESwFOxTest, OF3BGalpha0.8BGbeta0.8TrackerTest1 ) {
	testTracker( 34, "TrackerTest1" );
}

TEST_F(HandTrackerLKGREYwMSwBPwBGESwFOxTest, OF3BGalpha0.8BGbeta1.0TrackerTest1 ) {
	testTracker( 35, "TrackerTest1" );
}
